//121 Best Time to Buy and Sell Stock
/*
给定一段时间内每天的股票价格，已知你只可以买卖各一次，求最大的收益
输入输出样例：
	输入一个一维整数数组，表示每天的股票价格；输出一个整数，表示最大的收益

Input: [7,1,5,3,6,4]
Output: 5
*/
int maxProfit(vector<int> &prices)
{
	int sell = 0, buy = INT_MIN;
	for (int i = 0; i < prices.size(); ++i)
	{
		buy = max(buy, -prices[i]);
		sell = max(sell, buy + prices[i]);
	}
	return sell;
}